package nl.ypmits.utils.as3.view.simpledraw {
	import flash.display.DisplayObject;
	import flash.display.StageAlign;
	import flash.geom.Rectangle;

	/**
	 * @author Dave Lenz
	 */
	public class SimpleDrawAUtil {
		public static function align( dob : DisplayObject, align : String = "CENTER" ) : void {
			
			var obj : Rectangle = dob.getBounds( dob.parent );
			
			switch (align) {
				case "CENTER":
					dob.x = dob.y = -(dob.width * .5);
					break;
				case StageAlign.BOTTOM:
					obj.x = -(dob.width * .5);
					obj.y = -obj.height;
					break;
				case StageAlign.BOTTOM_LEFT:
					obj.y = -obj.height;
					break;
				case StageAlign.BOTTOM_RIGHT:
					obj.x = -obj.width;
					break;
				case StageAlign.LEFT:
					obj.y = -(obj.height * .5);
					break;
				case StageAlign.RIGHT:
					obj.x = -obj.width;
					obj.y = -(obj.height * .5);
					break;
				case StageAlign.TOP:
					obj.x = -(obj.width * .5);
					break;
				case StageAlign.TOP_LEFT:
					break;
				case StageAlign.TOP_RIGHT:
					obj.x = -(obj.width * .5);
					obj.y = -(obj.height * .5);
					break;
				}
		}
	}
}
